package com.xxd.spring.boot.demo.lihonghai.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxd.spring.boot.demo.lihonghai.entity.Grade;
import com.xxd.spring.boot.demo.lihonghai.mapper.GradeMapper;
import com.xxd.spring.boot.demo.lihonghai.service.GradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class GradeServiceImpl implements GradeService {
 @Autowired
    private GradeMapper gradeMapper;
   public int add(Grade grade){
       int insert=gradeMapper.insert(grade);
       return insert;
   }

    @Override
    public int update(Grade grade)
    {
        return gradeMapper.updateById(grade);
    }

    @Override
    public void deleteById1(Integer id) {
        gradeMapper.deleteById1(id);
    }

    @Override
    public void deleteById2(Integer id) {
        gradeMapper.deleteById2(id);
    }

    @Override
    public IPage<Grade> listpage(Page page, Map<String, Object> params)
    {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(params);
        Page respage =gradeMapper.selectPage(page,queryWrapper);
        return respage;
    }

    @Override
    public List<Grade> list(Map<String, Object> params)
    {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.setEntity(params);
            return gradeMapper.selectList(queryWrapper);
    }

    @Override
    public Grade selectById(Integer id) {
        return gradeMapper.selectById(id);
    }
}
